#!/bin/bash


function getTiming() {

        start=$1
        start_s=$(echo $start | cut -d '.' -f 1)
        start_ns=$(echo $start | cut -d '.' -f 2)
        end=$2
        end_s=$(echo $end | cut -d '.' -f 1)
        end_ns=$(echo $end | cut -d '.' -f 2)

        time=$(( ( 10#$end_s - 10#$start_s ) * 1000 + ( 10#$end_ns / 1000000 - 10#$start_ns / 1000000 ) ))

        if [ $time -gt 500 ] ; then
                echo "$3 $4 发送了一次请求，运单号为$5，耗时$time ms 超过500" >> result.log
        elif [ $time -gt 400 ] ; then
                echo "$3 $4 发送了一次请求，运单号为$5，耗时$time ms 超过400" >> result.log
        elif [ $time -gt 300 ] ; then
                echo "$3 $4 发送了一次请求，运单号为$5，耗时$time ms 超过300" >> result.log
        elif [ $time -gt 200 ] ; then
                echo "$3 $4 发送了一次请求，运单号为$5，耗时$time ms 超过200" >> result.log
        elif [ $time -gt 100 ] ; then
                echo "$3 $4 发送了一次请求，运单号为$5，耗时$time ms 超过100" >> result.log
        else
                echo "$3 $4 发送了一次请求，运单号为$5，耗时$time ms" >> result.log
        fi

}


head='logistics_interface={
            "Head":
            {
                "MessageCode":"1102",
                "PostalDeparlmentCode":"999",
                "MessageNo":"20191219155642",
                "EcCompanyId":"TTKD"
            },
            "Traces":[
                {
                    "mailNo":"'


body='",
                    "CheckMethod":"99",
                    "UserName":"登潮男装专营店",
                    "SenderAddress":
                    {
                        "CityCode":"320500",
                        "CountyCode":"320581",
                        "Street":"江苏省苏州市常熟市东南开发区庐山南路凯润毛绒纺织厂内B栋4楼&nbsp;",
                        "ProvinceCode":"320000"
                    },
                    "StaffCardID":"",
                    "InternalsName":"",
                    "SenderLatLng":"",
                    "OutletsNo":"KT51249900",
                    "StaffCode":"51203.2671",
                    "IDPseudoCode":"",
                    "StaffCardType":"",
                    "UnifiedSocialCreditCode":"330127198502072872",
                    "OrgCode":"",
                    "ReceiverPhone":"158****3733",
                    "UserPhone":"13140811333",
                    "UserId":"登潮男装专营店",
                    "OutletsName":"常熟市场部",
                    "CheckDate":"20191219145538",
                    "InternalsType":"",
                    "InternalsAmount":"1",
                    "UserType":"3",
                    "TaxRegNo":"",
                    "ReceiverName":"张**"
                }
            ]
        }'







for i in {1..2}
do
t=`date '+%Y-%m-%d %H:%M:%S.%N' | cut -b 1-23`
start=$(date +%s.%N)
#count=$((RANDOM %6))
#count=$(( 10#$count + 1 ))
mailNo=175566006test$i
msg=$head$mailNo$body
echo $msg
curl -H "isPublic:normal" -X POST -d $msg  http://10.15.180.21:7092/prnp_kernel_web/expressStatusInfo.do
end=$(date +%s.%N)

getTiming $start $end $t $mailNo
sleep 1
done

